<?php

namespace Log;
/**
 * \SeasLog日志
 * Class \SeasLog
 * @package Log
 */
class SeasLog
{
    public function __construct()
    {
    }

    public function __destruct()
    {
    }
    public static function setLogger($loggerName)
    {
        $lastLogger  = \SeasLog::getLastLogger();
        $logger =  \Core\Di::get('config')['seaslog']['logger'][$loggerName];
        if($lastLogger != $logger){
            \SeasLog::setLogger($logger);
        }
        return true;
    }

    /**
     * 设置sql日志
     * @param $message
     * @param array $context
     * @param string $module
     * @return mixed
     */
    public static function setSqlLog($message, array $context = array(), $module = '')
    {
        self::setLogger('sql');
        return \SeasLog::info($message, $context, $module);
    }

    public static function setRequestLog($message, array $context = array(), $module = '')
    {
        self::setLogger('request');
        return \SeasLog::info($message, $context, $module);
    }

    /**
     * 记录debug日志
     *
     * @param string|array $message
     * @param array        $context
     * @param string       $module
     */
    static public function debug($message, array $context = array(), $module = '')
    {
        self::setLogger('php');
        return \SeasLog::debug($message, $context, $module);
    }

    /**
     * 记录info日志
     *
     * @param string|array $message
     * @param array        $context
     * @param string       $module
     */
    static public function info($message, array $context = array(), $module = '')
    {
        self::setLogger('php');
        return \SeasLog::info($message, $context, $module);
    }

    /**
     * 记录notice日志
     *
     * @param string|array $message
     * @param array        $context
     * @param string       $module
     */
    static public function notice($message, array $context = array(), $module = '')
    {
        self::setLogger('php');
        return \SeasLog::notice($message, $context, $module);
    }

    /**
     * 记录warning日志
     *
     * @param string|array $message
     * @param array        $context
     * @param string       $module
     */
    static public function warning($message, array $context = array(), $module = '')
    {
        self::setLogger('php');
        return \SeasLog::warning($message, $context, $module);
    }

    /**
     * 记录error日志
     *
     * @param string|array $message
     * @param array        $context
     * @param string       $module
     */
    static public function error($message, array $context = array(), $module = '')
    {
        self::setLogger('php');
        return \SeasLog::error($message, $context, $module);
    }

    /**
     * 记录critical日志
     *
     * @param string|array $message
     * @param array        $context
     * @param string       $module
     */
    static public function critical($message, array $context = array(), $module = '')
    {
        self::setLogger('php');
        return \SeasLog::critical($message, $context, $module);
    }

    /**
     * 记录alert日志
     *
     * @param string|array $message
     * @param array        $context
     * @param string       $module
     */
    static public function alert($message, array $context = array(), $module = '')
    {
        self::setLogger('php');
        return \SeasLog::alert($message, $context, $module);
    }

    /**
     * 记录emergency日志
     *
     * @param string|array $message
     * @param array        $context
     * @param string       $module
     */
    static public function emergency($message, array $context = array(), $module = '')
    {
        self::setLogger('php');
        return \SeasLog::emergency($message, $context, $module);
    }

}